function strip_nonnumeric(that) {
	that.value = that.value.replace(/[^0-9]/g, '');
}

function strip_2digit(that) {
	if (that.value.length == 1){
		that.value = "0"+that.value;
	}else if(that.value.length > 2){
		that.value = that.value.substring(that.value.length-2,that.value.length);
	}	
}

function addSeparator(fldID){
	var posCaret=getPosition(fldID);
	var fldVal=fldID.value;

	if((fldVal.length===3||7||11)&&(fldVal.length===posCaret)){
		posCaret=posCaret+1;
	}

	nStr = fldVal.replace(/,/g,'');
	nStr += '';

	x=nStr.split('.');
	x1=x[0];
	x2=x.length>1?'.'+x[1]:'';
	var rgx=/(\d+)(\d{3})/;
	while (rgx.test(x1)){
		x1=x1.replace(rgx,'$1'+','+'$2');
	}
	fldID.value=x1+x2;
	setCaretPosition(fldID,posCaret);
}

function setCaretPosition(elem,caretPos){
	if(elem!=null){
		if(elem.createTextRange){
			varrange=elem.createTextRange();
			range.move('character',caretPos);
			range.select();
		}else{
			if(elem.selectionStart){
				elem.focus();
				elem.setSelectionRange(caretPos,caretPos);
			}else{
				elem.focus();
			}
		}
	}
}

function getPosition(amtFld){
	var iCaretPos=0;
	if(document.selection){
		amtFld.focus();
		varoSel=document.selection.createRange();
		oSel.moveStart('character',-amtFld.value.length);
		iCaretPos=oSel.text.length;
	}else if(amtFld.selectionStart||amtFld.selectionStart=='0'){
		iCaretPos=amtFld.selectionStart;
	}
	return(iCaretPos);
}
